<!DOCTYPE html>
<html>
  <head>
    <title>在线委托</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
  </head>
	<link rel="stylesheet" href="./css/common.css">
	<link rel="stylesheet" href="./css/sm.min.css">
	<link rel="stylesheet" href="./css/sm-extend.min.css">
	<script src="../js/jquery-2.1.1.js"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
	<script src="../js/min/modernizr-custom-v2.7.1.min.js" type="text/javascript"></script>
	<script src="../js/min/hammer-v2.0.3.min.js" type="text/javascript"></script>
	<script src="./js/zepto.js"></script>
	<script src="./js/sm.min.js" ></script>
	<script type='text/javascript' src='./js/sm-extend.min.js' charset='utf-8'></script>
	<script src="../js/min/modernizr-custom-v2.7.1.min.js" type="text/javascript"></script>
	<script src="./js/zepto.js" type="text/javascript"></script>
	<script src="./js/sm.js" type="text/javascript"></script>
  <body>
  <header class="bar bar-nav">
    <h1 class="title">在线委托</h1>
  </header>
<div class="content">
  <div class="list-block" style="margin-top:0;">
    <ul>
      <li>
        <div class="item-content item-link">
          <!-- <div class="item-media"><i class="icon icon-f7"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">城市</div>
              <div class="item-input" >
              <select id="city">
                <option value="珠海市">珠海市</option>
              </select>
            </div>
          </div>
        </div>
      </li>
      <li>
        <div class="item-content">
          <!-- <div class="item-media"><i class="icon icon-form-name"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">地址</div>
            <div class="item-input">
              <input type="text" placeholder="请输入房子地址" id="address">
            </div>
          </div>
        </div>
      </li>
      <li>
        <div class="item-content">
          <!-- <div class="item-media"><i class="icon icon-form-name"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">小区名称</div>
            <div class="item-input">
              <input type="text" placeholder="请输入小区名称" id="houseName">
            </div>
          </div>
        </div>
      </li>
      <li>
        <div class="item-content item-link">
          <!-- <div class="item-media"><i class="icon icon-form-name"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">房子户型</div>
            <div class="item-input" >
              <select id="houseLayout">
                <option value="三房两厅">三房两厅</option>
                <option value="三房一厅">三房一厅</option>
                <option value="两房两厅">两房两厅</option>
                <option value="一房一厅">一房一厅</option>
                <option value="四房两厅">四房两厅</option>
                
              </select>
            </div>
          </div>
        </div>
      </li>
      <li>
        <div class="item-content">
          <!-- <div class="item-media"><i class="icon icon-form-name"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">房子大小</div>
            <div class="item-input">
              <input type="number" placeholder="请输入房子大小" id="houseSize">
            </div>
          </div>
        </div>
      </li>
      <li>
        <div class="item-content item-link">
          <!-- <div class="item-media"><i class="icon icon-form-name"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">家居用品</div>
            <div class="item-input">
              <select id="appliances">
                <option value="家电家私齐全">家电家私齐全</option>
                <option value="有部分家私家电">有部分家私家电</option>
                <option value="无家私家电">无家私家电</option>
                
              </select>
            </div>
          </div>
        </div>
      </li>
      <li>
        <div class="item-content">
          <!-- <div class="item-media"><i class="icon icon-form-name"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">如何称呼</div>
            <div class="item-input">
              <input type="text" id="nickName" placeholder="请输入您的姓名" >
            </div>
          </div>
        </div>
      </li>
      <li>
        <div class="item-content">
          <!-- <div class="item-media"><i class="icon icon-form-name"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">联系电话</div>
            <div class="item-input">
              <input type="text" id="phone" placeholder="请输入联系电话" >
            </div>
          </div>
        </div>
      </li>
      <li class="align-top">
        <div class="item-content">
          <!-- <div class="item-media"><i class="icon icon-form-comment"></i></div> -->
          <div class="item-inner">
            <div class="item-title label">备注</div>
            <div class="item-input">
              <textarea id="userRemark" placeholder="请输入留言或备注"></textarea>
            </div>
          </div>
        </div>
      </li>
    </ul>
  </div>

  <div class="content-block">
    <div class="row">
      <div class="col-50"><a href="javaScript:cancle()" class="button button-big button-fill button-light">取消</a></div>
      <div class="col-50" onclick="save()" id="submitBtn"><a href="#" class="button button-big button-fill button-info" >提交</a></div>
    </div>
  </div>
  <div class="content-padded" style="text-align: -webkit-center;">
  <p>提交后我们将在30分钟后致电您</p>
  <p><span style="color: #0000ff;">客服热线：0756-2543354</span2></p>
</div>
</div>
<script src="../js/common.js"></script>
<script type="text/javascript">
window.$$=window.Zepto = Zepto;
var nonce="";//生成签名的随机串
var signature="";//签名
var timestamp="";//时间戳
var title="蓝居--定制租住生活";
var desc="房屋出租托管、租房、除甲醛除异味、保洁家修戳我！";
var sharLink="http://lanjushiye.com.cn/LanJuPublic/jsp/home.html";
var imgUrl="http://lanjushiye.com.cn/LanJuPublic/images/lanju.jpg";
$(document).ready(function(){  
	  var url = encodeURI(location.href.split('#')[0]);
	  $.ajax({
	         url: "../weixinImpl/getEncryptJsapiTicket.spring?rn="+(new Date().getTime()),
	         type: "POST",
	         data:{"url":url},
	         dataType: "json",
	         success: function(data){
	        	 if(data != null){
	        		 nonce=data.nonce;
		             signature=data.signature;
		             timestamp=data.timestamp;
		             loadWx();
	        	 }
	             
	          },
	          error:function(err){
	            console.log('异常');
	          }
	        });
});

function loadWx(){
	  wx.config({
		    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
		    appId: 'wxb3b7beee9190b2ef', // 必填，公众号的唯一标识wxd894029b9bdb4b67
		    timestamp: timestamp, // 必填，生成签名的时间戳
		    nonceStr: nonce, // 必填，生成签名的随机串
		    signature: signature,// 必填，签名
		    jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ'] // 必填，需要使用的JS接口列表
		});
	  wx.ready(function(){
		  //分享到朋友圈
		  wx.onMenuShareTimeline({
			    title: title, // 分享标题
			    link: sharLink, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
			    imgUrl: imgUrl, // 分享图标
			    desc: desc, // 分享描述
			    success: function () {
			    // 用户确认分享后执行的回调函数
				},
			cancel: function () {
			    // 用户取消分享后执行的回调函数
		    }
		});
		  //分享到朋友
		  wx.onMenuShareAppMessage({
			  title: title, // 分享标题
			  desc: desc, // 分享描述
			  link: sharLink, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
			  imgUrl: imgUrl, // 分享图标
			  type: 'link', // 分享类型,music、video或link，不填默认为link
			  dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
			  success: function () {
			  // 用户确认分享后执行的回调函数
			  },
			  cancel: function () {
			  // 用户取消分享后执行的回调函数
			  }
			  });
		  //分享到QQ
		  wx.onMenuShareQQ({
			  title: title, // 分享标题
			  desc: desc, // 分享描述
			  link: sharLink, // 分享链接
			  imgUrl: imgUrl, // 分享图标
			  success: function () {
			  // 用户确认分享后执行的回调函数
			  },
			  cancel: function () {
			  // 用户取消分享后执行的回调函数
			  }
			  });
	  });
	  
	  wx.error(function(res){
		
	  });
	  
}
function cancle(){
	history.go(-1);	
}
/** 保存 */
function save( ){
	var city = $("#city").val().trim(),
		address = $("#address").val(),
		houseName = $("#houseName").val().trim(),
		houseLayout = $("#houseLayout").val().trim(),
		houseSize = $("#houseSize").val().trim(),
		appliances = $("#appliances").val().trim(),
		nickName = $("#nickName").val().trim(),
		phone = $("#phone").val().trim(),
		userRemark = $("#userRemark").val().trim(),
		status = "1";
	
	if(isNull(nickName)){
		$$.toast("请输入如何称呼");
		return;
	}
	if(houseSize>100000){
		$$.toast("请输入正确的房屋大小");
		return;
	}
	if(!checkPhone(phone)){
		$$.toast("请输入正确的手机号码");
		return;
	}
	
	//
	$.ajax({
		type: "POST",
		dataType: "json",
		url: "../houseEntrust/add.do?rnd="+ Math.random(),
		data: {
			city : city,
			address : address,
			houseName : houseName,
			houseLayout : houseLayout,
			houseSize : houseSize,
			appliances :appliances,
			nickName :nickName,
			phone :phone,
			userRemark :userRemark,
			type : "3",	//房子类型（1-友家、2-整租、3-直租等）
			status : "1",
			phone : getCookie("phone")
		},
		success: function(data){
			if( data.resultCode=="0" ){
				$$.alert(data.msg||"提交成功",function(){//houseImg.html
			    window.location.href="./houseImg.html?houseId="+data.content.houseId;
// 				window.location.href="./weituoWay.html?houseId="+data.content.houseId;
				});
			}else{
				$$.alert(data.msg||"发起失败");
			}
		},
		error: function(e) {
			$$.toast("请求出错");
		}
	});
}
 function getCookie (name) 
{ 
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
 
        return unescape(arr[2]); 
    else 
        return null; 
} 
</script>
  </body>
</html>
